Popular Searches
Popular Course Categories
Popular Courses

REST API Basics

API & Database Integration

REST API Basics

REST API (Representational State Transfer Application Programming Interface) is a widely used approach for enabling applications, services, and systems to communicate with each other over a network using standard HTTP methods. REST APIs are commonly used in web applications, mobile applications, automation frameworks, microservices, cloud applications, and integration testing.

In software testing and Selenium automation, understanding REST APIs is important because modern applications often depend on backend APIs for authentication, user management, product information, search, orders, payments, and other business operations. API testing allows testers to validate backend functionality directly without depending entirely on the user interface.

REST APIs generally use HTTP methods such as GET, POST, PUT, PATCH, and DELETE to perform operations on resources. Data is commonly exchanged using formats such as JSON.

Course Resource: Selenium Training | Register for Course Demo


1. What is an API?

An API (Application Programming Interface) is a set of rules and mechanisms that allows one software application to communicate with another application or service.

For example, when a mobile application displays customer information, the application may send a request to a backend API. The API processes the request, communicates with the database or another service, and returns the required response.

Client Application

        |

        | HTTP Request

        v

      REST API

        |

        v

    Application

      Server

        |

        v

    Database

        |

        v

    HTTP Response

        |

        v

Client Application


2. What is REST?

REST stands for Representational State Transfer. It is an architectural style for designing network-based services.

REST uses standard web technologies, particularly HTTP, to allow clients and servers to communicate using resources and operations.

REST is not a programming language or a specific software tool. It is a set of architectural principles used to design APIs.


3. What is a REST API?

A REST API is an API designed according to REST architectural principles. It exposes resources through URLs and uses HTTP methods to perform operations on those resources.

For example, an API may expose a user resource through:

GET https://example.com/api/users

The server can return a JSON response containing user information.


4. Why are REST APIs Important in Testing?

REST API testing allows testers to validate backend functionality directly. API testing can be performed before, alongside, or independently of UI testing.

  • Validates backend functionality.
  • Tests business logic independently of the UI.
  • Helps identify server-side defects.
  • Provides faster feedback than many UI tests.
  • Can validate request and response data.
  • Supports automated testing.
  • Helps test microservices and integrations.
  • Can be integrated with CI/CD pipelines.
  • Can be combined with Selenium UI automation.
  • Allows negative and boundary testing.


5. REST API Architecture

A typical REST API architecture contains a client, API/server layer, business logic, database, and external services.

Client

   |

   | HTTP Request

   v

REST API Endpoint

   |

   v

Controller / Route

   |

   v

Business Logic

   |

   v

Database / External Service

   |

   v

Response

   |

   v

Client


6. Client and Server

The client is the application that sends requests to the server. The server receives requests, processes them, and returns responses.

ComponentResponsibility
ClientSends requests and consumes responses
ServerProcesses requests and generates responses
APIDefines the communication interface
DatabaseStores application data


7. REST Resources

In REST, information is represented as resources. A resource can represent a user, product, order, employee, customer, payment, or another business entity.

For example:

/users

/products

/orders

/customers

/payments

Each resource can have a unique URL or endpoint.


8. REST API Endpoint

An endpoint is a specific URL through which a client can interact with an API resource.

Example:

https://example.com/api/users

Specific user:

https://example.com/api/users/101

Here, /users represents the resource and /101 identifies a particular user.


9. HTTP Protocol

REST APIs commonly use the HTTP (HyperText Transfer Protocol) protocol for communication between clients and servers.

HTTP defines methods, headers, status codes, and other mechanisms used to communicate between systems.

HTTP ConceptPurpose
MethodDefines the requested operation
URLIdentifies the resource
HeadersProvide additional request or response information
BodyContains request or response data
Status CodeIndicates the result of the request


10. HTTP Methods

The most commonly used HTTP methods in REST APIs are:

MethodCommon Purpose
GETRetrieve data
POSTCreate a resource or submit data
PUTReplace or update a resource
PATCHPartially update a resource
DELETEDelete a resource


11. GET Request

The GET method is commonly used to retrieve information from a server.

GET /api/users

Example:

GET https://example.com/api/users

A successful response may contain a list of users.


12. GET Request for a Specific Resource

A GET request can retrieve a specific resource by including an identifier in the URL.

GET /api/users/101

This request asks the server for the user whose identifier is 101.


13. POST Request

The POST method is commonly used to submit data to the server and create a new resource.

POST /api/users

Example JSON request body:

{

  "name": "John",

  "email": "[email protected]",

  "role": "tester"

}


14. PUT Request

The PUT method is commonly used to replace or update an existing resource.

PUT /api/users/101

Example:

{

  "name": "John Updated",

  "email": "[email protected]",

  "role": "tester"

}


15. PATCH Request

The PATCH method is commonly used when only part of an existing resource needs to be updated.

PATCH /api/users/101

Example:

{

  "role": "admin"

}

Unlike a full replacement, PATCH is generally used for partial modifications.


16. DELETE Request

The DELETE method is used to request deletion of a resource.

DELETE /api/users/101

The server may return a success status indicating that the resource was deleted or that the deletion request was accepted.


17. CRUD Operations

REST APIs are commonly associated with CRUD operations.

CRUDHTTP MethodExample
CreatePOSTPOST /users
ReadGETGET /users/101
UpdatePUT/PATCHPUT /users/101
DeleteDELETEDELETE /users/101


18. API Request

An API request is the message sent by a client to a server.

A request can contain:

  • HTTP method.
  • URL or endpoint.
  • Path parameters.
  • Query parameters.
  • Headers.
  • Authentication information.
  • Request body.

POST /api/users

Content-Type: application/json

Authorization: Bearer <token>

 

{

  "name": "John",

  "email": "[email protected]"

}


19. API Response

An API response is the message returned by the server after processing a request.

A response can contain:

  • Status code.
  • Response headers.
  • Response body.
  • Error information.
  • Metadata.


20. HTTP Status Codes

HTTP status codes indicate the result of an HTTP request.

Status CodeMeaningCommon Usage
200OKSuccessful request
201CreatedResource successfully created
202AcceptedRequest accepted for processing
204No ContentSuccessful response without response body
400Bad RequestInvalid request
401UnauthorizedAuthentication required or invalid
403ForbiddenRequest understood but not permitted
404Not FoundResource or endpoint not found
405Method Not AllowedHTTP method not supported for the resource
409ConflictRequest conflicts with current resource state
500Internal Server ErrorUnexpected server-side error
502Bad GatewayGateway received an invalid upstream response
503Service UnavailableService temporarily unavailable


21. JSON in REST APIs

JSON (JavaScript Object Notation) is one of the most commonly used formats for exchanging structured data through REST APIs.

Example:

{

  "id": 101,

  "name": "John",

  "email": "[email protected]",

  "active": true

}

JSON represents information using objects, arrays, strings, numbers, booleans, and null values.


22. JSON Object

A JSON object contains key-value pairs.

{

  "name": "John",

  "age": 30,

  "active": true

}

Here:

  • name is a key with a string value.
  • age is a key with a numeric value.
  • active is a key with a boolean value.


23. JSON Array

A JSON array contains multiple values or objects.

{

  "users": [

    {

      "id": 1,

      "name": "John"

    },

    {

      "id": 2,

      "name": "David"

    }

  ]

}


24. Request Headers

HTTP headers provide additional information about a request.

Common request headers include:

HeaderPurpose
Content-TypeSpecifies the format of the request body
AcceptIndicates acceptable response formats
AuthorizationProvides authentication credentials or token
User-AgentIdentifies the client software


25. Content-Type Header

The Content-Type header tells the server what format is being sent in the request body.

For JSON:

Content-Type: application/json

Example:

POST /api/users

Content-Type: application/json

 

{

  "name": "John"

}


26. Accept Header

The Accept header indicates the response formats that the client can process.

Accept: application/json

This is commonly used when the client expects a JSON response.


27. Authentication in REST APIs

Many APIs require authentication to ensure that only authorized clients can access protected resources.

Common authentication mechanisms include:

  • Basic Authentication.
  • API Keys.
  • Bearer Tokens.
  • OAuth 2.0.
  • JWT-based authentication.


28. Bearer Token Authentication

A bearer token is commonly sent through the Authorization header.

Authorization: Bearer <access-token>

Example request:

GET /api/profile

Authorization: Bearer abc123token

Real access tokens should be handled securely and should not be exposed in source code or test reports.


29. API Key Authentication

Some APIs require an API key to identify or authorize the client.

An API key may be supplied through a header such as:

X-API-Key: <api-key>

The exact header name and authentication process depend on the API design.


30. Path Parameters

A path parameter identifies a specific resource within the URL.

GET /api/users/101

Here, 101 is the user identifier.

Another example:

GET /api/products/5001


31. Query Parameters

Query parameters are commonly used to filter, search, sort, or paginate resources.

GET /api/products?category=electronics

Multiple query parameters can be supplied:

GET /api/products?category=electronics&sort=price&page=2


32. Path Parameter vs Query Parameter

FeaturePath ParameterQuery Parameter
PurposeIdentify a resourceFilter or modify a request
Example/users/101/users?role=admin
Common UsageSpecific resourceSearch/filter/sort/pagination


33. Request Body

The request body contains data sent to the server, particularly for methods such as POST, PUT, and PATCH.

{

  "name": "John",

  "email": "[email protected]",

  "role": "tester"

}


34. Response Body

The response body contains data returned by the server.

{

  "id": 101,

  "name": "John",

  "email": "[email protected]",

  "role": "tester"

}


35. Statelessness in REST

One important REST principle is statelessness. Each request should contain the information necessary for the server to process that request.

The server should not depend on hidden client-session state to understand the meaning of an individual request.

Request 1

Client ----------------> Server

 

Request 2

Client ----------------> Server

 

Request 3

Client ----------------> Server

 

Each request contains the information

needed to process that request.


36. REST API URL Structure

A typical REST API URL may contain a base URL, API version, resource, identifier, and query parameters.

https://example.com/api/v1/users/101?active=true

PartExample
Protocolhttps
Hostexample.com
Base Path/api
Version/v1
Resource/users
Identifier/101
Query Parameter?active=true


37. API Versioning

API versioning allows an API provider to introduce changes while maintaining compatibility with existing clients.

A common URL-based approach is:

/api/v1/users

/api/v2/users

Other versioning strategies can use headers or other mechanisms depending on the API design.


38. Idempotency

Idempotency describes whether repeating the same request has the same intended effect as making it once.

GET, PUT, and DELETE are generally designed to be idempotent according to HTTP semantics, while POST is generally not idempotent.

Actual application behavior should still be verified against the API's documented contract.


39. Safe HTTP Methods

Some HTTP methods are defined as safe, meaning they are intended for read-only operations and should not request a state-changing action.

GET is the most common safe method.

GET /api/products


40. REST API Testing

REST API testing involves sending requests to API endpoints and validating the resulting responses.

Typical validation areas include:

  • Status code.
  • Response body.
  • Response headers.
  • Response schema.
  • Response time.
  • Business rules.
  • Authentication.
  • Authorization.
  • Error handling.
  • Data consistency.


41. API Testing Flow

Identify API Endpoint

        |

        v

Select HTTP Method

        |

        v

Prepare Headers

        |

        v

Prepare Authentication

        |

        v

Prepare Request Parameters

        |

        v

Prepare Request Body

        |

        v

Send Request

        |

        v

Receive Response

        |

        v

Validate Status Code

        |

        v

Validate Response Body

        |

        v

Validate Headers / Schema

        |

        v

Generate Test Result


42. Positive API Testing

Positive testing verifies that the API behaves correctly when valid input is provided.

Example:

POST /api/users

 

{

  "name": "John",

  "email": "[email protected]"

}

Possible expected result:

Status: 201 Created


43. Negative API Testing

Negative testing verifies how the API handles invalid, incomplete, unauthorized, or unexpected input.

Example:

POST /api/users

 

{

  "email": "invalid-email"

}

The API may return an appropriate client-error response according to its contract.


44. Boundary Testing in APIs

Boundary testing checks values at or around important limits.

For example, if a username has a maximum length of 50 characters, test cases can include:

  • 49 characters.
  • 50 characters.
  • 51 characters.
  • Empty value.
  • Null value where applicable.


45. API Validation

API validation verifies that the response satisfies the expected contract.

Common validations include:

HTTP Status Code

        +

Response Headers

        +

Response Body

        +

JSON Fields

        +

Data Types

        +

Business Rules

        =

API Validation


46. Response Body Validation

Suppose an API returns:

{

  "id": 101,

  "name": "John",

  "active": true

}

Tests can validate:

  • id exists.
  • id is numeric.
  • name is present.
  • active is boolean.
  • Values satisfy the expected business rules.


47. JSON Schema Validation

Schema validation verifies that a response follows the expected structural contract.

A schema can define expected properties and data types.

{

  "id": 101,

  "name": "John",

  "active": true

}

For example, a test can verify that:

  • id is a number.
  • name is a string.
  • active is a boolean.


48. API Testing Tools

Several tools can be used to develop and execute REST API tests.

ToolCommon Usage
PostmanManual and automated API testing
cURLCommand-line HTTP requests
Rest AssuredJava-based API automation
SoapUIAPI testing and service testing
JMeterPerformance and load testing
Swagger/OpenAPI toolsAPI documentation and exploration


49. Postman Basics

Postman is a popular tool for creating, sending, and validating API requests.

A typical Postman request can contain:

  • HTTP method.
  • Request URL.
  • Query parameters.
  • Headers.
  • Authorization.
  • Request body.
  • Tests.

Example:

GET https://example.com/api/users


50. cURL Basics

cURL is a command-line utility that can send HTTP requests.

Example GET request:

curl -X GET "https://example.com/api/users"

Example POST request:

curl -X POST "https://example.com/api/users" \

-H "Content-Type: application/json" \

-d '{"name":"John","email":"[email protected]"}'


51. REST Assured

REST Assured is a Java library commonly used to automate REST API testing.

It can be integrated with testing frameworks such as TestNG and JUnit.

REST Assured supports request creation, response validation, JSON processing, authentication, headers, parameters, and assertions.


52. REST Assured GET Example

import static io.restassured.RestAssured.*;

import static org.hamcrest.Matchers.*;

 

import org.testng.annotations.Test;

 

public class GetUserTest {

 

    @Test

    public void getUser() {

 

        given()

        .when()

            .get("https://example.com/api/users/101")

        .then()

            .statusCode(200);

    }

}


53. REST Assured POST Example

import static io.restassured.RestAssured.*;

 

import org.testng.annotations.Test;

 

public class CreateUserTest {

 

    @Test

    public void createUser() {

 

        String requestBody = """

        {

            "name": "John",

            "email": "[email protected]"

        }

        """;

 

        given()

            .contentType("application/json")

            .body(requestBody)

        .when()

            .post("https://example.com/api/users")

        .then()

            .statusCode(201);

    }

}


54. REST Assured Response Validation

REST Assured can validate response status codes and JSON fields.

given()

.when()

    .get("https://example.com/api/users/101")

.then()

    .statusCode(200)

    .body("id", equalTo(101));

This approach allows API tests to verify both HTTP behavior and response content.


55. Given-When-Then Structure

REST Assured commonly uses a readable Given-When-Then structure.

given()

    // Request setup

 

.when()

    // Send request

 

.then()

    // Validate response

SectionPurpose
given()Prepare request
when()Execute request
then()Validate response


56. Query Parameters with REST Assured

given()

    .queryParam("category", "electronics")

    .queryParam("page", 2)

.when()

    .get("https://example.com/api/products")

.then()

    .statusCode(200);


57. Path Parameters with REST Assured

given()

    .pathParam("id", 101)

.when()

    .get("https://example.com/api/users/{id}")

.then()

    .statusCode(200);


58. Headers with REST Assured

given()

    .header("Accept", "application/json")

    .header("Content-Type", "application/json")

.when()

    .get("https://example.com/api/users")

.then()

    .statusCode(200);


59. Authentication with REST Assured

REST Assured supports different authentication mechanisms depending on the API.

Example of bearer-token authentication:

given()

    .header("Authorization", "Bearer " + token)

.when()

    .get("https://example.com/api/profile")

.then()

    .statusCode(200);

Tokens should be stored and managed securely rather than hard-coded in source-controlled test code.


60. REST API Testing with TestNG

REST Assured can be combined with TestNG to create structured API automation suites.

import static io.restassured.RestAssured.*;

import static org.hamcrest.Matchers.*;

 

import org.testng.annotations.Test;

 

public class UserApiTest {

 

    @Test

    public void verifyUser() {

 

        given()

        .when()

            .get("https://example.com/api/users/101")

        .then()

            .statusCode(200)

            .body("id", equalTo(101));

    }

}


61. REST API Testing with Data Providers

TestNG Data Providers can be combined with REST Assured to execute the same API test against multiple data sets.

import static io.restassured.RestAssured.*;

import org.testng.annotations.DataProvider;

import org.testng.annotations.Test;

 

public class ApiDataDrivenTest {

 

    @DataProvider(name = "users")

    public Object[][] users() {

        return new Object[][] {

            {101},

            {102},

            {103}

        };

    }

 

    @Test(dataProvider = "users")

    public void getUserTest(int userId) {

 

        given()

        .when()

            .get("https://example.com/api/users/" + userId)

        .then()

            .statusCode(200);

    }

}


62. API Testing with Selenium

Selenium primarily automates web browsers and user-interface interactions, while REST API tools such as REST Assured are used to test backend API behavior.

Both approaches can be combined in an automation framework.

API Layer

   |

   | Create Test Data

   v

REST API

   |

   v

Database / Application

   |

   v

Selenium UI

   |

   v

Verify User Interface

For example, an API can create a user before Selenium opens the application and verifies that the user appears correctly in the UI.


63. API Testing vs UI Testing

FeatureAPI TestingUI Testing
LayerBackend/service layerUser interface
Browser RequiredUsually noUsually yes
Execution SpeedGenerally fasterGenerally slower
ValidationRequests and responsesVisible application behavior
Typical ToolsREST Assured, PostmanSelenium
Best UseBackend and integration validationEnd-user workflow validation


64. API Testing vs Selenium Testing

Selenium and API testing complement each other rather than performing exactly the same role.

API Testing

    |

    +-- Backend Validation

    +-- Request Validation

    +-- Response Validation

    +-- Business Logic

 

Selenium Testing

    |

    +-- Browser Automation

    +-- UI Validation

    +-- User Workflow

    +-- Visual Interaction


65. API Chaining

API chaining means using data returned from one API request as input for another API request.

Create User

    |

    v

Receive User ID

    |

    v

Get User Details

    |

    v

Update User

    |

    v

Delete User

For example, the ID returned from a POST request can be used in a subsequent GET, PUT, or DELETE request.


66. API Workflow Testing

A real application may require multiple API operations to be performed in sequence.

Login API

    |

    v

Receive Token

    |

    v

Get Products

    |

    v

Create Order

    |

    v

Get Order

    |

    v

Cancel Order

Testing such workflows helps verify that multiple API operations work correctly together.


67. API Response Time

API tests can also validate response-time expectations when performance requirements are defined.

Request

   |

   v

Start Timer

   |

   v

API Processing

   |

   v

Response

   |

   v

Stop Timer

   |

   v

Validate Response Time

Response-time checks should be based on documented requirements rather than arbitrary values.


68. API Error Handling

A good API should return meaningful responses when requests fail.

Common scenarios include:

  • Invalid input.
  • Missing required field.
  • Invalid authentication.
  • Insufficient authorization.
  • Resource not found.
  • Duplicate data.
  • Unsupported HTTP method.
  • Server-side failure.


69. API Security Testing Basics

API security testing checks whether APIs properly protect sensitive resources and enforce authentication and authorization requirements.

Basic areas include:

  • Authentication validation.
  • Authorization validation.
  • Token handling.
  • Input validation.
  • Sensitive-data exposure.
  • Access control.
  • HTTPS usage.
  • Rate limiting where applicable.

Security testing should be performed only in authorized environments.


70. Common API Testing Scenarios

ScenarioExample
Valid RequestValid user data
Invalid RequestMissing required field
AuthenticationValid/invalid token
AuthorizationUser accessing restricted resource
Not FoundInvalid resource ID
Duplicate DataExisting unique value
BoundaryMinimum/maximum values
Response ValidationStatus and JSON fields
PerformanceResponse-time requirement


71. Common REST API Mistakes

  • Using the wrong HTTP method.
  • Using an incorrect endpoint.
  • Sending invalid JSON.
  • Missing required headers.
  • Using incorrect authentication.
  • Ignoring HTTP status codes.
  • Validating only that a response exists.
  • Not validating response content.
  • Hard-coding credentials or tokens.
  • Not testing negative scenarios.
  • Ignoring API documentation.
  • Sharing production secrets in test code or reports.


72. Best Practices for REST API Testing

  • Understand the API contract before writing tests.
  • Use meaningful endpoint and test names.
  • Validate status codes.
  • Validate important response fields.
  • Validate response structure and schema where appropriate.
  • Test both positive and negative scenarios.
  • Use reusable request specifications.
  • Separate test data from test logic.
  • Use environment-specific configuration.
  • Never expose sensitive credentials in reports.
  • Use API automation in CI/CD pipelines.
  • Keep API tests independent whenever practical.
  • Use data-driven testing for multiple input combinations.
  • Combine API and UI automation when end-to-end validation requires both layers.


73. REST API Test Project Structure

src

|-- test

    |-- java

        |-- tests

        |   |-- UserApiTest.java

        |   |-- ProductApiTest.java

        |   |-- OrderApiTest.java

        |

        |-- requests

        |   |-- UserRequest.java

        |   |-- ProductRequest.java

        |

        |-- utilities

        |   |-- ConfigReader.java

        |   |-- JsonUtils.java

        |   |-- TokenManager.java

        |

        |-- data

        |   |-- UserDataProvider.java

        |   |-- ProductDataProvider.java

        |

        |-- models

            |-- User.java

            |-- Product.java


74. Complete REST API Testing Flow

Test Data

    |

    v

TestNG / JUnit

    |

    v

REST Assured

    |

    v

Request Specification

    |

    v

HTTP Request

    |

    v

REST API

    |

    v

Application / Database

    |

    v

HTTP Response

    |

    v

Status Validation

    |

    v

Body Validation

    |

    v

Schema Validation

    |

    v

Test Report


75. Practical REST API Example

Consider a user-management API that supports creating and retrieving users.

Step 1: Create User

POST /api/users

 

{

  "name": "John",

  "email": "[email protected]"

}

Step 2: Receive Response

{

  "id": 101,

  "name": "John",

  "email": "[email protected]"

}

Step 3: Retrieve User

GET /api/users/101

Step 4: Validate Response

Status Code = 200

id = 101

name = John

email = [email protected]


76. Practical Selenium + REST API Scenario

Suppose an automation framework needs to test an e-commerce application.

REST API

   |

   | Create Test User

   v

User Created

   |

   | Selenium

   v

Open Website

   |

   v

Login

   |

   v

Search Product

   |

   v

Add Product to Cart

   |

   v

Checkout

   |

   v

Verify Order

This approach can reduce unnecessary UI setup and allow API testing and UI testing to complement each other.


77. REST API and CI/CD

API automation can be executed as part of a CI/CD pipeline.

Developer Commit

       |

       v

Build

       |

       v

Unit Tests

       |

       v

API Tests

       |

       v

UI Automation

       |

       v

Reports

       |

       v

Deployment

API tests are often useful early in the pipeline because they can validate service behavior without requiring a browser.


78. REST API and Test Reports

API automation frameworks can generate test reports containing information such as:

  • Test name.
  • Endpoint.
  • HTTP method.
  • Status code.
  • Pass/fail result.
  • Response validation result.
  • Execution duration.
  • Error details.

Sensitive request or response information should be masked or excluded from reports when necessary.


79. REST API vs SOAP

FeatureRESTSOAP
TypeArchitectural styleProtocol
Common Data FormatOften JSONOften XML
TransportCommonly HTTP/HTTPSCommonly HTTP/HTTPS and other transports
ComplexityGenerally lightweightGenerally more formal and specification-heavy
UsageWeb APIs and modern servicesEnterprise/service integrations


80. Interview Questions on REST API Basics

1. What is an API?

An API is an interface that allows software applications or services to communicate with each other.

2. What does REST stand for?

REST stands for Representational State Transfer.

3. What is a REST API?

A REST API is an API designed using REST architectural principles and commonly accessed through HTTP.

4. What are the common HTTP methods?

GET, POST, PUT, PATCH, and DELETE are commonly used HTTP methods.

5. What is GET used for?

GET is generally used to retrieve resources.

6. What is POST used for?

POST is commonly used to submit data and create resources.

7. What is the difference between PUT and PATCH?

PUT is generally used for replacing a resource representation, while PATCH is generally used for partial modification.

8. What is a REST API endpoint?

An endpoint is a URL through which a client interacts with an API resource.

9. What is JSON?

JSON is a lightweight data-interchange format commonly used for REST API requests and responses.

10. What is an HTTP status code?

An HTTP status code indicates the result of an HTTP request.

11. What does status code 200 mean?

200 indicates that the request was successfully processed.

12. What does status code 201 mean?

201 indicates that a resource was successfully created.

13. What does status code 400 mean?

400 indicates that the server could not process the request because of invalid request information.

14. What does status code 401 mean?

401 indicates that authentication is required or the supplied authentication is not valid.

15. What does status code 404 mean?

404 indicates that the requested resource or endpoint could not be found.

16. What is API testing?

API testing validates API requests, responses, business rules, authentication, status codes, and data behavior.

17. What is REST Assured?

REST Assured is a Java library used for automating REST API tests.

18. Can REST Assured be used with TestNG?

Yes. REST Assured can be integrated with TestNG to create Java-based API automation suites.

19. What is API chaining?

API chaining is the process of using output from one API request as input for another request.

20. Can Selenium and API testing be used together?

Yes. Selenium can validate UI workflows while API automation validates backend services, and both can be combined in an end-to-end automation framework.


81. Quick Reference Table

ConceptDescription
APIInterface for software communication
RESTArchitectural style for network-based services
EndpointURL used to access an API resource
GETRetrieve data
POSTCreate or submit data
PUTReplace/update a resource
PATCHPartially update a resource
DELETEDelete a resource
JSONCommon data format for API communication
HeaderAdditional HTTP request/response information
Status CodeIndicates request result
Path ParameterIdentifies a resource in the URL path
Query ParameterFilters or modifies a request
REST AssuredJava library for REST API automation
PostmanTool for API development and testing


82. Learning Roadmap for REST API Testing

  1. Understand HTTP and HTTPS.
  2. Learn API and REST fundamentals.
  3. Understand resources and endpoints.
  4. Learn GET, POST, PUT, PATCH, and DELETE.
  5. Understand request and response structure.
  6. Learn HTTP status codes.
  7. Learn request and response headers.
  8. Understand JSON objects and arrays.
  9. Learn path and query parameters.
  10. Understand API authentication.
  11. Practice APIs using Postman.
  12. Learn cURL basics.
  13. Learn REST Assured.
  14. Integrate REST Assured with TestNG.
  15. Implement data-driven API testing.
  16. Implement response assertions.
  17. Learn schema validation.
  18. Implement API chaining.
  19. Combine API and Selenium testing.
  20. Integrate API tests with Maven and CI/CD.


83. Practical Exercises

  1. Send a GET request and validate the status code.
  2. Send a GET request using a path parameter.
  3. Send a GET request using query parameters.
  4. Create a POST request with JSON data.
  5. Update a resource using PUT.
  6. Partially update a resource using PATCH.
  7. Delete a resource using DELETE.
  8. Validate response headers.
  9. Validate important JSON response fields.
  10. Test invalid request data.
  11. Test invalid authentication.
  12. Create a REST Assured GET automation test.
  13. Create a REST Assured POST automation test.
  14. Integrate REST Assured with TestNG.
  15. Use a Data Provider for multiple API inputs.
  16. Implement API chaining.
  17. Create a reusable API request utility.
  18. Generate API automation reports.
  19. Execute API tests through Maven.
  20. Integrate API tests into a CI/CD pipeline.


84. Real-World API Automation Architecture

Test Data

    |

    v

Data Provider

    |

    v

API Test Class

    |

    v

Request Specification

    |

    v

REST Assured

    |

    v

REST API

    |

    v

Application / Database

    |

    v

Response

    |

    +---- Status Validation

    |

    +---- Header Validation

    |

    +---- Body Validation

    |

    +---- Schema Validation

    |

    +---- Business Validation

    |

    v

Test Report


85. Summary

REST API is an important technology for communication between modern applications and backend services. REST APIs commonly use HTTP methods such as GET, POST, PUT, PATCH, and DELETE to work with application resources.

For automation testers, understanding REST API basics is valuable because many modern applications depend heavily on backend services. API testing allows testers to validate backend functionality, request and response data, authentication, business rules, error handling, and integrations without relying entirely on the browser interface.

Tools such as Postman, cURL, and REST Assured can be used to work with REST APIs. In Java-based Selenium frameworks, REST Assured can be integrated with TestNG, Data Providers, Maven, reporting systems, and CI/CD pipelines.

API automation and Selenium UI automation can also work together. APIs can be used to prepare or validate test data, while Selenium can validate the corresponding user-interface workflows.


86. Course Resources

Learn more about Selenium automation, API testing, TestNG, Page Object Model, reporting, and related automation concepts:

Final Takeaway: REST API knowledge helps automation testers understand and validate the backend services that power modern applications. By combining REST API testing with Selenium, TestNG, REST Assured, data-driven testing, and CI/CD, testers can build broader and more maintainable automation solutions.

whatsapp